﻿#include "net.h"
#include "sys_plat.h"
#include "exmsg.h"
#include "pktbuf.h"
#include "debug.h"
#include "netif.h"
#include "net_plat.h"
#include "loop.h"
#include "ether.h"
#include "tools.h"
#include "timer.h"
#include "arp.h"
#include "ipv4.h"
#include "sock.h"
#include "raw.h"
#include "routetbl.h"
#include "dgram.h"

/**
 * @brief 初始化网络
 */
net_err_t net_init()
{
    DBG_INFO(DBG_NET_LEVEL, "net init begin!");

    tools_init();

    net_plat_init();
    pktbuf_init();
    netif_init();
    exmsg_init();

    timer_init();

    ether_init();
    arp_init();
    ipv4_init();
    routetbl_init();

    socket_init();
    raw_init();
    dgram_init();

    loop_init();

    DBG_INFO(DBG_NET_LEVEL, "net init end!");
    return NET_ERR_OK;
}

/**
 * @brief 拉起网络
 */
net_err_t net_start()
{
    // todo...
    exmsg_start();
    return NET_ERR_OK;
}